<!DOCTYPE html>
<html lang="en">

<head>
  <meta charset="UTF-8">
  <meta http-equiv="X-UA-Compatible" content="IE=edge">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <title>Document</title>
  <style>
    li {
      width: 300px;
      height: 30px;
      background-color: rgb(127, 78, 78);
      margin-top: 10px;
    }
  </style>
</head>

<body>
  <div id="app">
    <button @click="changeLen">改变length</button>
    <ul>
      <li v-for="(item,index) in arr" @click="changeLi(index)" :key="index">
        {{item}}
      </li>
    </ul>
  </div>
  <script src="./vue.global.js"></script>
  <script>
    const { createApp } = Vue;
    const app = createApp({
      data() {
        return {
          arr: [1, 2, 3, 4]
        }
      },
      methods: {
        changeLi(index) {
          this.arr[index] = 'aaa'
          console.log(this.arr);

        },
        changeLen() {
          this.arr.length = 0;
          console.log(this.arr);

        }
      }
    })
    app.mount('#app')
  </script>
</body>

</html>